<template>
	<view class="content" :style="'background:#F7F7F7;'">
		<view class="toptitle" :style="'top:0;padding-top:' + zhuangtai + 'px;height:' + (aniosgaodu+zhuangtai) + 'px;'">
			{{title}}
		</view>
		<view :style="'height:' + topgaodu + 'px;'"></view>
		<view class="my-view-css userinfo" :style="{background:'#E9564F;','margin-top':'30rpx;'}">
			<view class="uerinfo-left">
				<image class="avatar" :src="avatar" mode=""></image>
				<view class="user-info-list">
					<text class="font30" :style="'color:#FFFFFF;'">{{nickname}}</text>
					<view class="user-info-list-bottom">
						<image :src="level_image" mode=""></image>
						<text class="font28 fontw" :style="'color:#FFFFFF;'">Lv.{{level || 0}}</text>
					</view>
				</view>
			</view>
			<view class="userinfo-right">
				<image :src="app_config.gold_coin_image" mode=""></image>
				<text class="font28" :style="'color:#FFFFFF;'">{{app_config.gold_coin_name}}：{{gold_coin || 0}}</text>
			</view>
		</view>
		<view class="my-view-css center-list" :style="{background:'#FFFFFF;'}">
			<view class="item-view" @click="goToAllLuttery">
				<image src="../../../static/all-luttery.png" mode=""></image>
				<text class="font28 ":style="{color:'#111111;','margin-bottom':'21rpx;'}">全部抽奖</text>
				<text class="font30 fontw500" :style="{color:'#AEAEAE;'}">{{join_prizedraw_num || 0}}</text>
			</view>
			<view class="item-view" @click="goToCreateLutteyList">
				<image src="../../../static/all-createluttery.png" mode=""></image>
				<text class="font28 ":style="{color:'#111111;','margin-bottom':'21rpx;'}">发起抽奖</text>
				<text class="font30 fontw500" :style="{color:'#AEAEAE;'}">{{create_prizedraw_num || 0}}</text>
			</view>
			<view class="item-view" @click="goToMySuccess">
				<image src="../../../static/all-luttery-list.png" mode=""></image>
				<text class="font28 ":style="{color:'#111111;','margin-bottom':'21rpx;'}">中奖记录</text>
				<text class="font30 fontw500" :style="{color:'#AEAEAE;'}">{{win_prizedraw_num || 0}}</text>
			</view>
		</view>
		<swiper class="swiper-item" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item, index) in banner" :key="index">
				<image style="width: 100%;height: 100%;" :src="item.image" @click="goToOtherApp(item)" mode="heightFix"></image>
			</swiper-item>
		</swiper>
		<view class="my-view-css bottom-list" :style="{background:'#FFFFFF;'}">
			<view class="item border-bottom" @click="goToMyOrder">
				<view class="item-left">
					<image class="image1" src="../../../static/all-order.png" mode=""></image>
					<text class="font30" :style="{color:'#111111;'}">我的订单</text>
				</view>
				<image class="next-image" src="../../../static/neck-bload.png" mode=""></image>
			</view>
			<view class="item border-bottom" @click="goToMyBargining">
				<view class="item-left">
					<image class="image2" src="../../../static/Bargaining/my-bariging.png" mode=""></image>
					<text class="font30" :style="{color:'#111111;'}">我的砍价</text>
				</view>
				<image class="next-image" src="../../../static/neck-bload.png" mode=""></image>
			</view>
			<view class="item border-bottom" @click="goToAnswer">
				<view class="item-left">
					<image class="image2" src="../../../static/help-i.png" mode=""></image>
					<text class="font30" :style="{color:'#111111;'}">常见问题</text>
				</view>
				<image class="next-image" src="../../../static/neck-bload.png" mode=""></image>
			</view>
			<view class="item border-bottom">
				<view class="item-left">
					<image class="image3" src="../../../static/link.png" mode=""></image>
					<text class="font30" :style="{color:'#111111;'}">{{other_link[0].name}}</text>
				</view>
				<image class="next-image" src="../../../static/neck-bload.png" mode=""></image>
			</view>
			<button class="item" type="default" open-type="contact">
				<view class="item-left">
					<image class="image4" src="../../../static/kf.png" mode=""></image>
					<text class="font30" :style="{color:'#111111;'}">联系客服</text>
				</view>
				<image class="next-image" src="../../../static/neck-bload.png" mode=""></image>
			</button>
		</view>
		<tabbar ref='tabbar'></tabbar>
	</view>
</template>

<script>
	var util = require('@/js/util.js')
	import tabbar from '@/components/tabBar/tabBar'
	export default {
		components:{
			tabbar
		},
		data() {
			return {
				zhuangtai: 20,
				aniosgaodu: 48,
				topgaodu: 68,
				is_iphone:false,
				title:'我的	',
				banner:[],
				avatar:'',
				level_image:'',
				level:'',
				gold_coin:'',
				nickname:'',
				app_config:'',
				join_prizedraw_num:'',
				create_prizedraw_num:'',
				win_prizedraw_num:'',
				other_link:[]
			};
		},
		onShareAppMessage() { // 分享 buttom share
			return {
				title: '抽奖助手',
				path: '/pages/index/index?parent_id='+uni.getStorageSync('member_id')+'&prizedraw_id='+this.luttery_id
			}
		},
		onLoad() {
			this.app_config = uni.getStorageSync("appconfig")
			this.createtitle();
			let pages = getCurrentPages();
			let route = pages[pages.length - 1].route;
			this.$refs['tabbar'].gettabid(route);
		},
		onShow() {
			this.getMyIndex()
		},
		methods:{
			goToOtherApp(item){
				if(item.type == 2){
					uni.navigateToMiniProgram({
						appId: item.other_appid,
						path: item.other_url,
						success(res) {
							console.log(res,"打开成功")
						},
						fail: (e) => {
							console.log(e,"打开失败")
							uni.showToast({
								title:'参数不正确',
								icon:'none'
							})
						}
					})
				}
			},
			goToMyBargining(){
				uni.navigateTo({
					url:'../bargaining/myBargining'
				})
			},
			goToAnswer(){
				uni.navigateTo({
					url:'myCommonProblem'
				})
			},
			goToMySuccess(){
				uni.navigateTo({
					url:'lutterySuccesPrize'
				})
			},
			goToMyOrder(){
				uni.navigateTo({
					url:'myOrderList'
				})
			},
			goToCreateLutteyList(){
				uni.navigateTo({
					url:'createLutteryList'
				})
			},
			goToAllLuttery(){
				uni.navigateTo({
					url:'allLutteryList'
				})
			},
			getMyIndex(){
				let _self = this
				uni.request({
					url: util.getUrl("member/index"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation':uni.getStorageSync("token")
					},
					data:{
					},
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
							_self.banner = res.data.data.banner
							_self.avatar = res.data.data.avatar
							_self.level_image = res.data.data.level_image
							_self.level = res.data.data.level
							_self.gold_coin = res.data.data.gold_coin
							_self.nickname = res.data.data.nickname
							_self.join_prizedraw_num =res.data.data.join_prizedraw_num
							_self.create_prizedraw_num = res.data.data.create_prizedraw_num
							_self.win_prizedraw_num = res.data.data.win_prizedraw_num
							_self.other_link = res.data.data.other_link
						}else{
							if(res.data.code == 500){
								uni.navigateTo({
									url:'../../../pages/login/login'
								})
							}
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					},
				});
			},
			createtitle() {
				var that = this;
				uni.getSystemInfo({
					success: function(res) {
						console.log(res);
						that.zhuangtai = res.statusBarHeight;
						var a = res.system.split(' ');
						if (a[0] == 'iOS') {
							that.aniosgaodu = 44;
							that.is_iphone = true
						} else {
							that.aniosgaodu = 48;
						}
						that.topgaodu = that.aniosgaodu + parseInt(that.zhuangtai)
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.bottom-list{
		display: flex;
		flex-direction: column;
		align-items: center;
		.item{
			width: 100%;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			padding: 30upx 32upx;
			justify-content: space-between;
			background-color: rgba(0,0,0,0);
			margin: 0;
			line-height: 1;
			&::after{
				border: none;
				background: none;
			}
			.next-image{
				width: 20upx;
				height: 31upx;
			}
			.item-left{
				display: flex;
				align-items: center;
				.image1{
					width: 36upx;
					height: 39upx;
					margin-right: 19upx;
				}
				.image2{
					width: 39upx;
					height: 39upx;
					margin-right: 19upx;
				}
				.image3{
					width: 38upx;
					height: 36upx;
					margin-right: 19upx;
				}
				.image4{
					width: 43upx;
					height: 43upx;
					margin-right: 19upx;
				}
			}
		}
		.border-bottom{
			border-bottom: 2upx solid #EBEBEB;
		}
	}
	.swiper-item{
		width: 690upx;
		height: 205upx;
		border-radius: 20upx;
		background: #FFFFFF;
		margin-bottom: 30upx;
	}
	.center-list{
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding: 30upx 0;
		box-sizing: border-box;
		.item-view{
			display: flex;
			align-items: center;
			flex-direction: column;
			image{
				width: 80upx;
				height: 80upx;
				border-radius: 50%;
				margin-bottom: 21upx;
			}
		}
	}
	.userinfo{
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 32upx;
		.userinfo-right{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 210upx;
			height: 52upx;
			background: rgba(0,0,0,0.2);
			border-radius: 26upx;
			image{
				width: 34upx;
				height: 34upx;
				margin-right: 10upx;
			}
		}
		.uerinfo-left{
			display: flex;
			align-items: center;
			.avatar{
				width: 90upx;
				height: 90upx;
				margin-right: 32upx;
				border-radius: 10upx;
			}
			.user-info-list{
				display: flex;
				flex-direction: column;
				.user-info-list-bottom{
					display: flex;
					align-items: center;
					margin-top: 28upx;
					image{
						width: 30upx;
						height: 30upx;
						margin-right: 10upx;
					}
				}
			}
		}
	}
	.my-view-css{
		width: 690upx;
		border-radius: 20upx;
		margin-bottom: 30upx;
	}
	.content{
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 750upx;
		background: #F7F7F7;
		font-family: PingFang SC;
	}
	.toptitle {
		background: none;
		position: fixed;
		z-index: 98;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 32px;
		color: #333;
		background: #FFFFFF;
		font-size: 36upx;
	}
	.footTabList{
		display: flex;
		align-items: center;
		justify-content: space-around;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 750rpx;
		font-size: 24rpx;
		z-index: 98;
		padding-top: 12rpx;
		.listitem{
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 100rpx;
			image{
				width: 42rpx;
				height: 42rpx;
				margin-bottom: 15rpx;
			}
		}
	}
</style>
